package cn.stylefeng.guns.modular.api.controller;

import cn.stylefeng.guns.modular.ctm.entity.Ctm;
import cn.stylefeng.guns.modular.ctm.service.CtmService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 招聘模块管理
 */
@Controller
@RequestMapping("/api/recruit")
@Api(tags = "招聘岗位")
@CrossOrigin
public class ApiCTMRecruitController extends BaseController {

    @Autowired
    private CtmService ctmService;
    private Logger log = LoggerFactory.getLogger(this.getClass());

    @GetMapping(value = "/page")
    @ApiOperation(value = "岗位分页列表", notes = "岗位分页列表")
    @ResponseBody
    public ResponseData page(Page page, Ctm ctm) {
        return ResponseData.success(ctmService.selectByPage(page, ctm));
    }

    @GetMapping(value = "/{inputJobId}")
    @ApiOperation(value = "岗位详情", notes = "岗位详情")
    @ResponseBody
    public ResponseData selectInfoById(@PathVariable("inputJobId") String id) {
        return ResponseData.success(ctmService.selectInfoById(id));
    }

    @GetMapping(value = "/collectionPost/{inputJobId}")
    @ApiOperation(value = "收藏岗位", notes = "收藏岗位")
    @ResponseBody
    public ResponseData collectionPost(@PathVariable("inputJobId") String inputJobId) {
        ctmService.collectionPost(inputJobId);
        return ResponseData.success();
    }

    @GetMapping(value = "/uncollectPost/{inputJobId}")
    @ApiOperation(value = "取消收藏岗位", notes = "取消收藏岗位")
    @ResponseBody
    public ResponseData uncollectPost(@PathVariable("inputJobId") String inputJobId) {
        ctmService.uncollectPost(inputJobId);
        return ResponseData.success();
    }

    @GetMapping(value = "/collectionPostPage")
    @ApiOperation(value = "收藏岗位列表", notes = "收藏岗位列表")
    @ResponseBody
    public ResponseData collectionPostPage(Page page, Ctm ctm) {
        return ResponseData.success(ctmService.collectionPostPage(page, ctm));
    }

    @GetMapping(value = "/notInterested/{inputJobId}")
    @ApiOperation(value = "不感兴趣", notes = "不感兴趣")
    @ResponseBody
    public ResponseData notInterested(@PathVariable("inputJobId") String inputJobId) {
        ctmService.notInterested(inputJobId);
        return ResponseData.success();
    }

    @GetMapping(value = "/cancelNotInterested/{inputJobId}")
    @ApiOperation(value = "取消不感兴趣", notes = "取消不感兴趣")
    @ResponseBody
    public ResponseData cancelNotInterested(@PathVariable("inputJobId") String inputJobId) {
        ctmService.cancelNotInterested(inputJobId);
        return ResponseData.success();
    }

    @GetMapping(value = "/notInterestedPage")
    @ApiOperation(value = "不感兴趣列表", notes = "不感兴趣列表")
    @ResponseBody
    public ResponseData notInterestedPage(Page page, Ctm ctm) {
        return ResponseData.success(ctmService.notInterestedPage(page, ctm));
    }

    @GetMapping(value = "/workList")
    @ApiOperation(value = "工种列表", notes = "工种列表")
    @ResponseBody
    public ResponseData workList() {
        return ResponseData.success(ctmService.workList());
    }

    @GetMapping(value = "/countyList")
    @ApiOperation(value = "地区列表", notes = "地区列表")
    @ResponseBody
    public ResponseData countyList() {
        return ResponseData.success(ctmService.countyList());
    }

    @GetMapping(value = "/hotJob")
    @ApiOperation(value = "热招职位", notes = "热招职位")
    @ResponseBody
    public ResponseData hotJob() {
        return ResponseData.success(ctmService.hotJob());
    }

}